/* eslint-disable @typescript-eslint/no-var-requires */
const { defineConfig } = require('@vue/cli-service');
const APP_NAME = require('./package.json').name;
const path = require('path');
// const publicPath = `/microapps/${APP_NAME}/`;

module.exports = defineConfig({
  // publicPath,
  outputDir: `dist/${APP_NAME}`,
  transpileDependencies: true,
  devServer: {
    allowedHosts: 'all',
    // 配置跨域请求头，解决开发环境的跨域问题
    headers: {
      'Access-Control-Allow-Origin': '*',
    },
    proxy: {
      '/api/': {
        target: 'http://192.168.104.151:30080',
        secure: false,
        logLevel: 'debug',
        pathRewrite: {
          '^/api': '',
          changeOrigin: true,
        },
        xfwd: false,
      },
    },
  },
  css: {
    loaderOptions: {
      scss: {
        additionalData: `@import "@/assets/css/variables.scss";` //引入全局变量
      }
    }
  },
  configureWebpack: {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src'),
      },
      alias: {
        '~': path.resolve(__dirname, 'src')
      }
    },

    // output: {
    //   // 微应用的包名，这里与主应用中注册的微应用名称一致
    //   library: APP_NAME,
    //   // 将你的 library 暴露为所有的模块定义下都可运行的方式
    //   libraryTarget: 'umd',
    //   // 按需加载相关，设置为 webpackJsonp_微应用名称 即可
    //   chunkLoadingGlobal: `webpackJsonp_${APP_NAME}`,
    // },
  },
});
